require("../../../../../@babel/runtime/helpers/Arrayincludes");
var e = require("../../../../../@babel/runtime/helpers/regeneratorRuntime"),
  t = require("../../../../../@babel/runtime/helpers/objectSpread2"),
  r = require("../../../../../@babel/runtime/helpers/slicedToArray"),
  n = require("../../../../../@babel/runtime/helpers/asyncToGenerator");
Component({
  data: {
    list: [],
    showBack: !0
  },
  properties: {
    content: null
  },
  methods: {
    getRecommend: function () {
      var i = this;
      return n(e().mark((function n() {
        var a, o, s, u, d, c, l, m, h, p, b;
        return e().wrap((function (e) {
          switch (e.prev = e.next) {
            case 0:
              return a = i.data.content, o = a.mode, s = a.prov_id, u = a.city_id, d = a.latitude, c = a.longitude, l = a.uuid, m = {
                uu_id: l,
                mode: o,
                class_ids: i.data.content.class.map((function (e) {
                  return e.id
                })).join(","),
                prov_id: s,
                city_id: u,
                latitude: d,
                longitude: c,
                userLatitude:d?d:"",
                userLongitude:c?c:""
              }, e.next = 10, $.request[o == 1 ? "GET/business/seek/rent/pageList" : o == 2 ? "GET/business/for/rent/pageList" : "GET/business/recruit/worker/pageList"](t(t({}, m), {}, {
                hits: "1",
                pageNum: 1,
                status:3,
                pageSize: 15,
                cityId:wx.getStorageSync('userLocationCity').id
              }));
            case 10:
              h = e.sent, p = r(h, 1), p[0].data.data.map(item => {
                item.mode = o
                item.title = item.description;
                item.time = item.createTime
                item.timestamp = Date.parse(item.time) / 1000
                if (item.coverImageUrlList) {
                  if (item.coverImageUrlList.length > 0) {
                    item.cover = item.coverImageUrlList[0]
                  }
                }
                item.class = [{
                  name:o==5?item.driverTypeName:item.modelName,
                  value: item.modelName
                }]
                item.labels = {
                  address: {
                    name: "设备所在地",
                    value: item.provinceText + item.cityText + item.place
                  }
                }
                if (item.mfg) {
                  item.labels.manufacture_date = {
                    name: "出厂日期",
                    value: item.mfg
                  }
                }
                if (item.rent_price) {
                  item.labels.rent_price = {
                    name: "租赁价格",
                    value: item.rent ? `￥${item.rent?item.rent:0}元/月` : "￥-元/月"
                  }
                }
                if (item.number) {
                  item.labels.wanted_num = {
                    name: "数量",
                    value: item.number + "台"
                  }
                }
                if (item.worked_hour) {
                  item.labels.worked_hour = {
                    name: "租赁时间",
                    value: item.worked_hour + "小时"
                  }
                }
                if (item.leaseTerm) {
                  item.labels.rent_days = {
                    name: "租赁时间",
                    value: item.leaseTerm
                  }
                }
                if (item.factoryYears) {
                  item.labels.manufacture_limit = {
                    name: "出厂年限",
                    value: item.factoryYears + '年以内'
                  }
                }
              }), 20002 === (b = p[0]).code && i.setData({
                list: b.data.data
              });
            case 14:
            case "end":
              return e.stop()
          }
        }), n)
      })))()
    },
    onBackShowMore: function () {
      var e = this.data.content.mode;
      $.router.push("/pages/index/index", {
        mode: e
      })
    }
  },
  lifetimes: {
    attached: function () {
      this.getRecommend();
      var e = getCurrentPages(),
        t = e[e.length - 2],
        r = null == t ? void 0 : t.route;
      r && r.includes("details") && this.setData({
        showBack: !1
      })
    }
  }
});